package datamining.code.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import datamining.code.connection.OracleConnection;

public class TransactionDAO {
	Connection connection = OracleConnection.getConnection();
	public synchronized void create(String[] str) throws SQLException{
		String sql = "INSERT INTO EMPRESTIMO(idemprestimo, idusuario, idartefato, dataemprestimo, datadevoprev, datadevreal) VALUES(?,?,?,?,?,?)";
		PreparedStatement stmt;
		try {
			stmt = this.connection.prepareStatement(sql);
			stmt.setInt(1, Integer.parseInt(str[0]));
			stmt.setInt(2, Integer.parseInt(str[1]));
			stmt.setInt(3, Integer.parseInt(str[2]));
			stmt.setString(4, str[3]);
			stmt.setString(5, str[4]);
			stmt.setString(6, str[5]);
			stmt.execute();
//			System.out.println("Executed: "+str[0]+" "+str[1]+" "+str[2]+" "+str[3]+" "+str[4]+" "+str[5]+" ");
			stmt.close();			
		} catch (SQLException e) {
			e.printStackTrace();
		} 
	}

}
